/**
 *
 */
import Util;
import OpenApi;

import EndpointUtil;

extends OpenApi;

init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('xixikf-autotest', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }

  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}
model CommerInRequest {
  data?: string(name='Data'),
}

model CommerInResponseBody = {
  requestId?: string(name='RequestId', description='Id of the request'),
  success?: string(name='Success'),
}

model CommerInResponse = {
  headers: map[string]string(name='headers'),
  body: CommerInResponseBody(name='body'),
}

async function commerInWithOptions(request: CommerInRequest, runtime: Util.RuntimeOptions): CommerInResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('CommerIn', '2021-07-20', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function commerIn(request: CommerInRequest): CommerInResponse {
  var runtime = new Util.RuntimeOptions{};
  return commerInWithOptions(request, runtime);
}

model CommerOutRequest {
  data?: string(name='Data'),
}

model CommerOutResponseBody = {
  code?: string(name='Code'),
  data?: string(name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId', description='Id of the request'),
  success?: boolean(name='Success'),
}

model CommerOutResponse = {
  headers: map[string]string(name='headers'),
  body: CommerOutResponseBody(name='body'),
}

async function commerOutWithOptions(request: CommerOutRequest, runtime: Util.RuntimeOptions): CommerOutResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('CommerOut', '2021-07-20', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function commerOut(request: CommerOutRequest): CommerOutResponse {
  var runtime = new Util.RuntimeOptions{};
  return commerOutWithOptions(request, runtime);
}

